package com.example.util.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Slf4j
public class NumberUtil {

    /**
     * @param numLength  生成字符的长度
     * @param cycleTimes 循环次数
     * @param beginNum   起始数字
     */
    public static List<String> addFixLenthNumber(Integer numLength, Integer cycleTimes, Integer beginNum) {

        int seed = 1;
        if (beginNum != null && beginNum.intValue() != 0) {
            seed = beginNum + 1;
        }
        List<String> collect = Stream.iterate(seed, item -> item + 1).limit(cycleTimes)

                .map(item -> String.valueOf(item))
                .map(item -> {

                    while (item.length() < numLength) {
                        item = "0" + item;
                    }
                    return item;

                })
                .collect(Collectors.toList());
        return collect;
    }


}
